
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import "texture2d.h"
#import "Triangle.h"



////////////////////////////////////////
// Constants
#define kBrushOpacity      (1.0 / 3.0)
#define kBrushPixelStep     3
#define kBrushScale         2
#define kLuminosity         0.75
#define kSaturation         1.0


////////////////////////////////////////
// interface PaintingView
// obj->responder->view->paintingView
////////////////////////////////////////

@interface PaintingView : UIView <ShapeDataSource> {
@private

  /**
   * openGl context
   */
   EAGLContext *context;

  /**
   * The pixel dimensions of the backbuffer
   */
   GLint backingWidth;
   GLint backingHeight;
   
   /** 
    * OpenGL names for the renderbuffer and 
    * framebuffers used to render to this view.
    */
   GLuint viewRenderbuffer;
   GLuint viewFramebuffer;
   
   /**
    * OpenGL name for the depth buffer that is 
    * attached to viewFramebuffer, if it exists 
    * (0 if it does not exist).
    */
   GLuint depthRenderbuffer;
   
   /**
    * texture iamge size
    */
   GLuint imageWidth;
   GLuint imageHeight;

   GLuint textureId;

   CGPoint m_Location;
   CGPoint m_PrevLocation;
   Boolean m_FirstTouch;
  
   int m_MovingAngle;

   Texture2D *m_Text;
   Triangle *m_Triangle;

   Boolean needsUpdate;   
}

@property(nonatomic, readwrite) CGPoint location;
@property(nonatomic, readwrite) CGPoint prevLocation;
@property(nonatomic, readwrite) int movingAngle;

- (void)render;
- (void)setBrushColorWithRed:(CGFloat)red 
                       green:(CGFloat)green 
                        blue:(CGFloat)blue;

@end
